<template>
  <section v-loading="loading" class="cms-body">

    <div class="cms-list-header">
      <el-button type="primary" icon="el-icon-plus" @click="routerLink('/tag/save','save',0)" v-perms="'/tag/save'">添加</el-button>
      <el-select v-model="params.isDisplay" @change="goQuery">
        <el-option label="禁用状态" value=""></el-option>
        <el-option label="不禁用" value="0"></el-option>
        <el-option label="禁用" value="1"></el-option>
      </el-select>
      <cms-input label="标签名称" v-model="params.tagName"></cms-input>
      <el-button @click="goQuery()">查询</el-button>
    </div>

    <el-table :data="tableData" stripe style="width: 100%" @selection-change="checkIds">
      <el-table-column type="selection" width="35" align="right"></el-table-column>
      <el-table-column prop="id" label="ID" width="50" align="center"></el-table-column>
      <el-table-column prop="tagName" label="名称" align="left"></el-table-column>
      <el-table-column prop="tagSort" label="排序" align="center" width="75"></el-table-column>
      <el-table-column prop="isDisplay" label="启用状态" align="center" width="75">
        <div slot-scope="scope">
          <span v-if="scope.row.isDisplay==0">启用</span>
          <span v-if="scope.row.isDisplay==1">禁用 </span>
        </div>
      </el-table-column>
      <el-table-column prop="createTime" label="创建日期" align="center" width="120"></el-table-column>

      <el-table-column prop="name" label="操作" align="center" width="80">
        <div slot-scope="scope">
          <cms-button type="edit" @click.native="routerLink('/tag/update','update',scope.row.id)" v-perms="'/tag/update'"></cms-button>
          <cms-button type="delete" @click.native="deleteBatch($api.contentTagDelete,scope.row.id)" v-perms="'/tag/delete'"></cms-button>
        </div>
      </el-table-column>
    </el-table>
    <!-- 表格底部 -->
    <div class="cms-list-footer ">
      <div class="cms-left">
        <el-button :disabled="disabled" @click="deleteBatch($api.contentTagDelete,ids)" v-perms="'/tag/delete'">批量删除
        </el-button>
      </div>
      <!-- cms分页组件 -->
      <cms-pagination :total="total" @change="getPages"></cms-pagination>
    </div>
  </section>
</template>

<script>
  import listMixins from '@/mixins/list';
  import va from "@/rules";

  export default {
    mixins: [listMixins],
    data() {
      let checkTagName = va.checkTagName('');
      let required = va.required('此项必填');
      return {
        params: {//只需要业务参数
          tagName: '',
          isDisplay: '',
          pageNo: 1,
          pageSize: 10,
        },
        rules: {//校验规则
          name: [required, checkTagName],
          updateName: [required],
        }
      };
    },
    methods: {
      goQuery() {
        this.getTableData(this.params);
      }
    },
    created() {
      this.initTableData(this.$api.contentTagPageList, this.params);
    }
  };
</script>
<style scoped>
</style>
